package org.particles.gui.statistic;

import java.util.TimerTask;

import org.particles.gui.GuiUtil;
import org.particles.gui.WorldTimeTask;

/**
 * updates statistic in StatisticPanel.
 * properties worldTimeTask and simCtrlPanel must be set
 * before using this class.
 */
public class StatisticTask extends TimerTask {
	private WorldTimeTask worldTimeTask;
	private UpdateStatisticAction updateStatisticAction;

	@Override
	public void run() {
		if(!worldTimeTask.isRunning()) {
			return;
		}
		updateStatisticAction.actionPerformed(GuiUtil.emptyActionEvent());
	}

	public void setWorldTimeTask(final WorldTimeTask worldTimeTask) {
		this.worldTimeTask = worldTimeTask;
	}

	public void setUpdateStatisticAction(UpdateStatisticAction updateStatisticAction) {
		this.updateStatisticAction = updateStatisticAction;
	}

}
